home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / JTools / Janim / unvscomp.asm < prev    next >
Encoding:
Assembly Source File  |  1991-03-27  |  4.9 KB  |  159 lines

  1. \ JForth Port of Jim Kent's unvscomp.asm
  2. \ by Martin Kees
  3. \ The original docs:
  4. \ unvscomp.asm  Copyright 1987 Dancing Flame all rights reserved.
  5. \
  6. \ This file contains a single function which is set up to be called from
  7. \ C.  Ie the parameters are on the stack instead of registers.
  8. \       decode_vkplane(in, out, linebytes)
  9. \ where in is a bit-plane's worth of vertical-byte-run-with-skips data
  10. \ and out is a bit-plane that STILL has the image from last frame on it.
  11. \ Linebytes is the number of bytes-per-line in the out bitplane, and it
  12. \ should certainly be noted that the external pointer variable ytable
  13. \ must be initialized to point to a multiplication table of
  14. \ 0*linebytes, 1*linebytes ... n*linebytes  before this routine is called.
  15. \ The format of "in":
  16. \   Each column of the bitplane is compressed separately.  A 320x200
  17. \   bitplane would have 40 columns of 200 bytes each.  The linebytes
  18. \   parameter is used to count through the columns, it is not in the
  19. \   "in" data, which is simply a concatenation of columns.
  20. \
  21. \   Each columns is an op-count followed by a number of ops.
  22. \   If the op-count is zero, that's ok, it just means there's no change
  23. \   in this column from the last frame.
  24. \   The ops are of three classes, and followed by a varying amount of
  25. \   data depending on which class.
  26. \       1. Skip ops - this is a byte with the hi bit clear that says how many
  27. \          rows to move the "dest" pointer forward, ie to skip. It is non-
  28. \          zero
  29. \       2. Uniq ops - this is a byte with the hi bit set.  The hi bit is
  30. \          masked down and the remainder is a count of the number of bytes
  31. \          of data to copy literally.  It's of course followed by the
  32. \          data to copy.
  33. \       3. Same ops - this is a 0 byte followed by a count byte, followed
  34. \          by a byte value to repeat count times.
  35. \   Do bear in mind that the data is compressed vertically rather than
  36. \   horizontally, so to get to the next byte in the destination (out)
  37. \   we add linebytes instead of one!
  38. \
  39. anew task_decode
  40.  
  41. 400 value ytablesize          \ defaults for 320x200 display
  42.  40 value ybytesize  
  43. v: ytable ytable OFF   
  44.  
  45.  
  46. : calc.ytable ( -- )
  47.   ytable freevar
  48.   MEMF_PUBLIC ytablesize allocblock ytable !
  49.   ytable @ IF-NOT ." No memory for ytable"
  50.                 abort
  51.            THEN
  52.   0
  53.   ytablesize 2/ 0 do dup 
  54.                      ytable @ i 2* + w! 
  55.                      ybytesize +
  56.                   loop
  57.   drop
  58. ;
  59.  
  60.  
  61. ASM decode_vkplane ( in out linebytes --- )
  62.     movem.l    a2-a3/d5,-(rp)  ; save registers 
  63.     move.l    (dsp)+,a2
  64.     adda.l  a4,a2 
  65.     move.l    (dsp)+,a0
  66.     adda.l  a4,a0
  67.     move.w    d7,d2
  68.     move.l  (dsp)+,d7
  69.     callcfa ytable
  70.     move.l  $0(a4,tos.l),tos 
  71.     move.l  d7,a3
  72.     adda.l  a4,a3
  73.     move.w    d2,d4    \ make a copy of linebytes to use as a counter
  74.     bra    1$    \ And go to the "columns" loop
  75.     
  76. 2$:    move.l    a2,a1     \ get copy of dest pointer
  77.     clr.w    d0      \ clear hi byte of op_count
  78.     move.b    (a0)+,d0  \ fetch number of ops in this column
  79.     bra    3$      \ and branch to the "op" loop.
  80.  
  81. 4$:    clr.w    d1      \ clear hi byte of op
  82.     move.b    (a0)+,d1  \ fetch next op
  83.     bmi    5$        \ if hi-bit set branch to "uniq" decoder
  84.     beq     6$      \ if it's zero branch to "same" decoder
  85.  
  86.               \ otherwise it's just a skip
  87.     add.w    d1,d1      \ use amount to skip as index into word-table
  88.     adda.w    0(a3,d1.w),a1
  89.     dbra.w    d0,4$     \ go back to top of op loop
  90.     bra    7$        \ go back to column loop
  91.  
  92.             \ here we decode a "vertical same run"
  93. 6$:    move.b    (a0)+,d1  \ fetch the count
  94.     move.b    (a0)+,d3  \ fetch the value to repeat
  95.     move.w    d1,d5     \ and do what it takes to fall into a "tower"
  96.     asr.w    #3,d5     \ d5 holds # of times to loop through tower
  97.     and.w    #7,d1     \ d1 is the remainder
  98.     add.w    d1,d1
  99.     add.w    d1,d1
  100.     neg.w    d1
  101.     jmp    34(pc,d1.w)            \ why 34?  8*size of tower
  102.                                      \ instruction pair, but the extra 2's
  103.                                      \ pure voodoo.
  104. 8$:    move.b    d3,(a1)
  105.     adda.w    d2,a1
  106.     move.b    d3,(a1)
  107.     adda.w    d2,a1
  108.     move.b    d3,(a1)
  109.     adda.w    d2,a1
  110.     move.b    d3,(a1)
  111.     adda.w    d2,a1
  112.     move.b    d3,(a1)
  113.     adda.w    d2,a1
  114.     move.b    d3,(a1)
  115.     adda.w    d2,a1
  116.     move.b    d3,(a1)
  117.     adda.w    d2,a1
  118.     move.b    d3,(a1)
  119.     adda.w    d2,a1
  120.     dbra.w    d5,8$
  121.     dbra.w    d0,4$
  122.     bra.l    7$
  123.  
  124.                           \ here we decode a "unique" run
  125. 5$:    and.b    #$7f,d1   \ setting up a tower as above....
  126.     move.w    d1,d5
  127.     asr.w    #3,d5
  128.     and.w    #7,d1
  129.     add.w    d1,d1
  130.     add.w    d1,d1
  131.     neg.w    d1
  132.     jmp    34(pc,d1.w)
  133. 9$:    move.b    (a0)+,(a1)
  134.     adda.w    d2,a1
  135.     move.b    (a0)+,(a1)
  136.     adda.w    d2,a1
  137.     move.b    (a0)+,(a1)
  138.     adda.w    d2,a1
  139.     move.b    (a0)+,(a1)
  140.     adda.w    d2,a1
  141.     move.b    (a0)+,(a1)
  142.     adda.w    d2,a1
  143.     move.b    (a0)+,(a1)
  144.     adda.w    d2,a1
  145.     move.b    (a0)+,(a1)
  146.     adda.w    d2,a1
  147.     move.b    (a0)+,(a1)
  148.     adda.w    d2,a1
  149.     dbra.w    d5,9$      \ branch back up to "op" loop
  150. 3$:     dbra.w    d0,4$      \ branch back up to "column loop"
  151.  
  152.     \  now we've finished decoding a single column
  153. 7$:    addq.l    #1,a2  \ so move the dest pointer to next column
  154. 1$:    dbra.w    d4,2$  \ and go do it again what say?
  155.     movem.l    (rp)+,a2-a3/d5
  156.     move.l  (dsp)+,d7
  157. end-code
  158.